cmake_minimum_required(VERSION 2.8.3)
project(xrobot)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

set(OpenCV_DIR $ENV{OpenCV_DIR})
# set(OpenCV_DIR /home/ghowoght/Software/opencv4/opencv-4.5.1/build)


## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  message_generation
  roscpp
  rospy
  serial
  std_msgs
  tf
  cv_bridge
  sensor_msgs
  image_transport
  dynamic_reconfigure
)

find_package(OpenCV)
message(STATUS "OpenCV status:")
message(STATUS "    Opencv version: ${OpenCV_VERSION}")   
message(STATUS "    Opencv include: ${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS})

find_package(Eigen3 REQUIRED)

# add_message_files(
#   FILES
# )
# generate_messages(
#   DEPENDENCIES
# )

catkin_package(
 CATKIN_DEPENDS
 message_runtime
)

# 头文件路径
include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${Eigen3_INCLUDE_DIRS}
)

# 生成可执行文件
add_executable( robot_node src/robot_node.cpp )
#该项让编译器知道要注意编译顺序
add_dependencies(robot_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 

# 链接库
target_link_libraries(robot_node ${catkin_LIBRARIES})

# 生成可执行文件
add_executable( img_node src/img_node.cpp )
#该项让编译器知道要注意编译顺序
add_dependencies(img_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 

# 链接库
target_link_libraries(img_node 
                      ${catkin_LIBRARIES}
                      ${OpenCV_LIBS}
                      )

# 生成可执行文件
add_executable( laser_node src/laser_node.cpp )
#该项让编译器知道要注意编译顺序
add_dependencies(laser_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 

# 链接库
target_link_libraries(laser_node 
                      ${catkin_LIBRARIES}
                      )

# 生成可执行文件
add_executable( odom2txt src/odom2txt.cpp )
#该项让编译器知道要注意编译顺序
add_dependencies(odom2txt ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 

# 链接库
target_link_libraries(odom2txt 
                      ${catkin_LIBRARIES}
                      )

# 生成可执行文件
add_executable( read_imu_odom src/read_imu_odom.cpp )
#该项让编译器知道要注意编译顺序
add_dependencies(read_imu_odom ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 
# 链接库
target_link_libraries(read_imu_odom 
                      ${catkin_LIBRARIES}
                      )

# 生成可执行文件
add_executable( robot_node_v2 src/robot_node_v2.cpp )
#该项让编译器知道要注意编译顺序
add_dependencies(robot_node_v2 ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 
# 链接库
target_link_libraries(robot_node_v2 
                      ${catkin_LIBRARIES}
                      )
# 生成可执行文件
add_executable( record_tf src/record_tf.cpp )
#该项让编译器知道要注意编译顺序
add_dependencies(record_tf ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 
# 链接库
target_link_libraries(record_tf 
                      ${catkin_LIBRARIES}
                      )
